<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include.inc.jsp"%>

<script type="text/javascript">

var role_setting = {
			check: {
				enable: true,
			},
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onCheck: onCheck
			}
		};


		function beforeClick(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("user_updateRole_tree");
			zTree.checkNode(treeNode, !treeNode.checked, null, true);
			return false;
		}
		function onCheck(e, treeId, treeNode) { 
			var zTree = $.fn.zTree.getZTreeObj("user_updateRole_tree"),
			nodes = zTree.getCheckedNodes(true);
			var ids = [];
			for (var i=0, l=nodes.length; i<l; i++) {
				if(nodes[i].id != -1){
					ids.push(nodes[i].id);
				}
			}
			$("#roleIds").val(ids);
		}

      $(function(){
         $.post("${path}/role/treeData?ids=${ids}",function(data){
              $.fn.zTree.init($("#user_updateRole_tree"), role_setting, data);
          },"json");
          
        });
</script>
<div class="bjui-pageContent">
	<form method="post" action="${path }/admin/updateRole"  data-reload-navtab="true" class="pageForm" data-callback="ajaxCallback" data-toggle="validate">
		<input type="hidden" name="userIds" value="${userIds}"/>
		<input type="hidden" id="roleIds"  name="roleIds" value="${roleIds}">
		
		<div class="pageFormContent" data-layout-h="0">
			    <div class="suggestion">
	                <span class="sugicon"><span class="strong colorgorning2">当前操作提示：</span>
			        	<span class="colorgorningage">用户名为[${userNames}]的角色将会更新为选中角色！</span>
					</span>
	            </div>
	             <div class="formdiv">
					<div id="menuContent" class="menuContent" >
						<ul id="user_updateRole_tree" class="ztree" style="margin-top: 0; margin-left: 180px"></ul>
					</div>
				</div>
		</div>
		<div class="bjui-footBar" style="text-align: center;">
			<ul style="margin-left: 30%">
				<li style="float: left"><div class="buttonActive"><div class="buttonContent"><button  type="submit" class="btn-default" data-icon="edit" >确认更新</button></div></div></li>
				<li style="float: left"><div class="button"><div class="buttonContent"><button type="button" class="btn-close" data-icon="close" >取消更新</button></div></div></li>
			</ul>
		</div>
	</form>
</div>


